package com.gitee.wsl.compose.animation.transition

import androidx.compose.animation.core.FiniteAnimationSpec
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.VisibilityThreshold
import androidx.compose.animation.core.spring
import androidx.compose.animation.expandIn
import androidx.compose.animation.shrinkOut
import androidx.compose.runtime.Stable
import androidx.compose.ui.Alignment
import androidx.compose.ui.unit.IntSize

//展开动画。该动画会使对象从一个较小的尺寸逐渐展开到一个较大的尺寸。
@Stable
fun Transition.In.expand(
    animationSpec: FiniteAnimationSpec<IntSize> =
        spring(
            stiffness = Spring.StiffnessMediumLow,
            visibilityThreshold = IntSize.VisibilityThreshold
        ),
    expandFrom: Alignment = Alignment.BottomEnd,
    clip: Boolean = true,
    initialSize: (fullSize: IntSize) -> IntSize = { IntSize(0, 0) },
) = expandIn(animationSpec,expandFrom,clip,initialSize)



//水平展开动画。该动画会使对象从一个较窄的宽度逐渐展开到一个较宽的宽度。
@Stable
fun Transition.In.expandHorizontally(
    animationSpec: FiniteAnimationSpec<IntSize> =
        spring(
            stiffness = Spring.StiffnessMediumLow,
            visibilityThreshold = IntSize.VisibilityThreshold
        ),
    expandFrom: Alignment.Horizontal = Alignment.End,
    clip: Boolean = true,
    initialWidth: (fullWidth: Int) -> Int = { 0 },
) = androidx.compose.animation.expandHorizontally(animationSpec,expandFrom,clip,initialWidth)

//垂直展开动画。该动画会使对象从一个较短的高度逐渐展开到一个较高的高度。
@Stable
fun Transition.In.expandVertically(
    animationSpec: FiniteAnimationSpec<IntSize> =
        spring(
            stiffness = Spring.StiffnessMediumLow,
            visibilityThreshold = IntSize.VisibilityThreshold
        ),
    expandFrom: Alignment.Vertical = Alignment.Bottom,
    clip: Boolean = true,
    initialHeight: (fullHeight: Int) -> Int = { 0 },
) = androidx.compose.animation.expandVertically(animationSpec, expandFrom, clip, initialHeight)
